package com.zhouyu.service;

import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.Date;
import java.util.Map;

//@Component
public class UserService implements DisposableBean {

//	@Autowired
	private OrderService orderService;

	/*@Autowired
	private DefaultListableBeanFactory beanFactory;

	@Autowired
	private AnnotationConfigApplicationContext applicationContext;*/

	public void test(){
		System.out.println(orderService);
	}

	@Bean
	public User user(){
		System.out.println("UserService 来构建 User");
		return new User();
	}

	@Autowired
	public void test2(OrderService orderService){
		System.out.println("2" + orderService);
	}

	@PreDestroy
	public void a(){
		System.out.println("销毁之前");
	}


	@Override
	public void destroy() throws Exception {
		System.out.println("userService 销毁");
	}

	public void setOrderService(OrderService orderService) {
		this.orderService = orderService;
	}
}
